import fetch from '@/utils/fetch'

export function getRoomList(areaIds, params) {
	return fetch({
	    url: '/uc/v1/mgt/room',
	    method: 'get',
		headers: {'x-area-id': areaIds},
	    params
  	})
}

export function getRoomDetail(id) {
	return fetch({
	    url: `/uc/v1/mgt/room/${id}`,
	    method: 'get'
  	})
}

export function createRoom(data) {
	return fetch({
		url: '/uc/v1/mgt/room',
		method: 'post',
		data
	})
}

export function modifyRoom(id, data) {
	return fetch({
	    url: `/uc/v1/mgt/room/${id}`,
	    method: 'patch',
	    data
	})
}

export const purposeList = [
          {value: "1", label: '住宅'},
          {value: "2", label: '商用'},
          {value: "3", label: '混合'},
          {value: "4", label: '设备房'}
        ];

//根据房间信息拉取住户信息
export function getResidentList(room_id){
	return fetch({
		url:`/uc/v2/mgt/resident/${room_id}`,
		method:"get"
	})
}

//删除住户人员
export function deleteResident(user_id,roomid,device_type){
	return fetch({
		url:`/uc/v2/resident/room/${user_id}/${roomid}/${device_type}`,
		method:"delete"
	})
}

//编辑身份标识
export function updateUser(user_id,data){
	return fetch({
		url:`/uc/v2/mgt/resident/user/${user_id}`,
		method:"patch",
		data
	})
}

//添加住户
export function addUser(roomid,data,device_type){
	return fetch({
		url:`/uc/v2/resident/room/user/${roomid}/${device_type}`,
		method:"post",
		data
	})
}

//根据住户id拉取住户信息
export function getUserDetail(user_id){
	return fetch({
		url:`/uc/v1/mgt/resident/${user_id}`,
		method:"get"
	})
}